#include "BDTestBase.h"
#include "BDTestUtils.h"
#include <sstream>

DECLARE_TEST_VAR(Test_1)
{

};

DECLARE_TEST_N(Test_1, BDTestBase, 1)

DECLARE_EXAMPLE(Test_1)
{
	// 1. new shape
	AllocPainterParamShape(4);
	GetPainterParamShape(0)->set_type(PainterRefreshParam_Shape_ShapeType_SHAPE_CIRCLE);
	GetPainterParamShape(0)->mutable_circle()->set_x(m_iGazePointX);
	GetPainterParamShape(0)->mutable_circle()->set_y(m_iGazePointY);
	GetPainterParamShape(0)->mutable_circle()->set_r(50);
	GetPainterParamShape(0)->mutable_circle()->set_line_color(PainterRefreshParam_Shape_Color_COLOR_BLACK);
	GetPainterParamShape(0)->mutable_circle()->set_fill_color(PainterRefreshParam_Shape_Color_COLOR_WHITE);

	GetPainterParamShape(1)->set_type(PainterRefreshParam_Shape_ShapeType_SHAPE_CIRCLE);
	GetPainterParamShape(1)->mutable_circle()->set_x(100);
	GetPainterParamShape(1)->mutable_circle()->set_y(100);
	GetPainterParamShape(1)->mutable_circle()->set_r(50);
	GetPainterParamShape(1)->mutable_circle()->set_line_color(PainterRefreshParam_Shape_Color_COLOR_BLACK);
	GetPainterParamShape(1)->mutable_circle()->set_fill_color(PainterRefreshParam_Shape_Color_COLOR_RED);

	GetPainterParamShape(2)->set_type(PainterRefreshParam_Shape_ShapeType_SHAPE_CIRCLE);
	GetPainterParamShape(2)->mutable_circle()->set_x(500);
	GetPainterParamShape(2)->mutable_circle()->set_y(500);
	GetPainterParamShape(2)->mutable_circle()->set_r(50);
	GetPainterParamShape(2)->mutable_circle()->set_line_color(PainterRefreshParam_Shape_Color_COLOR_BLACK);
	GetPainterParamShape(2)->mutable_circle()->set_fill_color(PainterRefreshParam_Shape_Color_COLOR_YELLOW);

	GetPainterParamShape(3)->set_type(PainterRefreshParam_Shape_ShapeType_SHAPE_CIRCLE);
	GetPainterParamShape(3)->mutable_circle()->set_x(500);
	GetPainterParamShape(3)->mutable_circle()->set_y(100);
	GetPainterParamShape(3)->mutable_circle()->set_r(50);
	GetPainterParamShape(3)->mutable_circle()->set_line_color(PainterRefreshParam_Shape_Color_COLOR_BLACK);
	GetPainterParamShape(3)->mutable_circle()->set_fill_color(PainterRefreshParam_Shape_Color_COLOR_GREEN);

	// 2. calculate param
	bool isOverlapped1 = BDTestUtils::CalculateOverlap(GetPainterParamShape(0)->circle().x(), GetPainterParamShape(0)->circle().y(), GetPainterParamShape(1)->circle().x(), GetPainterParamShape(1)->circle().y(), 50);
	bool isOverlapped2 = BDTestUtils::CalculateOverlap(GetPainterParamShape(0)->circle().x(), GetPainterParamShape(0)->circle().y(), GetPainterParamShape(2)->circle().x(), GetPainterParamShape(2)->circle().y(), 50);
	bool isOverlapped3 = BDTestUtils::CalculateOverlap(GetPainterParamShape(0)->circle().x(), GetPainterParamShape(0)->circle().y(), GetPainterParamShape(3)->circle().x(), GetPainterParamShape(3)->circle().y(), 50);

	// 3. add param
	AllocDetailParamItem(5);
	GetDetailParamItem(0)->set_key("Overlap1");
	GetDetailParamItem(0)->set_value(isOverlapped1 ? "Yes" : "No");
	GetDetailParamItem(1)->set_key("Overlap2");
	GetDetailParamItem(1)->set_value(isOverlapped2 ? "Yes" : "No");
	GetDetailParamItem(2)->set_key("Overlap3");
	GetDetailParamItem(2)->set_value(isOverlapped3 ? "Yes" : "No");
	GetDetailParamItem(3)->set_key("GazePoint");
	GetDetailParamItem(3)->set_value(isOverlapped3 ? "Yes" : "No");
	GetDetailParamItem(4)->set_key("Attention");
	ostringstream os;
	os << m_iAttention;
	GetDetailParamItem(4)->set_value(os.str());

	Notify();
	
}